<?php

require_once('functions/pageLoad.php');

$page_title = 'Help';

$additionalMeta = '<script type="text/javascript" src="/library/mootools.js"></script>
<script type="text/javascript">
window.addEvent(\'domready\', function() {
	
	//create our Accordion instance
	var myAccordion1 = new Accordion($(\'accordion1\'), \'h3.toggler\', \'div.element\', {
		opacity: false,
		display: -1,
		onActive: function(toggler, element){
			toggler.setStyle(\'color\', \'#41464D\');
		},
		onBackground: function(toggler, element){
			toggler.setStyle(\'color\', \'#528CE0\');
		}
	});

	var myAccordion2 = new Accordion($(\'accordion2\'), \'h3.toggler\', \'div.element\', {
		opacity: false,
		display: -1,
		onActive: function(toggler, element){
			toggler.setStyle(\'color\', \'#41464D\');
		},
		onBackground: function(toggler, element){
			toggler.setStyle(\'color\', \'#528CE0\');
		}
	});

});
</script>
';

// user help

$sql = "SELECT id, question, answer FROM faqs WHERE user = 1 ORDER BY id";
$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

while($help_rs=mysql_fetch_assoc($query)){

$user_content.='<h3 class="toggler">'.ucfirst($help_rs['question']).'</h3>
		<div class="element">
		'.ucfirst(str_replace("\r\n", "<br />", $help_rs['answer'])).'
		</div>';

}

// tradesman help

$sql = "SELECT id, question, answer FROM faqs WHERE tradesman = 1 ORDER BY id";
$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

while($help_rs=mysql_fetch_assoc($query)){

$tradesman_content.='<h3 class="toggler">'.ucfirst($help_rs['question']).'</h3>
		<div class="element">
		'.ucfirst(str_replace("\r\n", "<br />", $help_rs['answer'])).'
		</div>';
}


include('includes/meta.php');
include('includes/header.php');
include('includes/navigation.php');

?>

<h1>Help</h1>

<p class="noTop">Welcome to the help section, click on a question below to view the answer. If you can't find the answer to your query, please feel free to <a href="/contact-us">contact us</a>.</p>

<h2>User help</h2>

<div id="accordian1">

<?php echo $user_content; ?>

</div>

<h2>Tradesman help</h2>

<div id="accordian2">

<?php echo $tradesman_content; ?>

</div>

<?php 

include('includes/rightColumn.php');
include('includes/footer.php');

?>